﻿namespace SuperModel.BehaviorModel
{
    using Castle.Core.Interceptor;

    /// <summary>
    /// The base property set filter
    /// </summary>
    public abstract class BaseSetFilter : IPropertySetFilter
    {
        /// <summary>
        /// Gets or sets the property name
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// Execute the Invocation
        /// </summary>
        /// <param name="invocation">
        /// The invocation.
        /// </param>
        /// <param name="propertyName">
        /// The property name.
        /// </param>
        /// <returns>
        /// A value indicating whether to continue.
        /// </returns>
        public bool Execute(IInvocation invocation, string propertyName)
        {
            if (propertyName == PropertyName)
            {
                return ExecuteInternal(invocation);
            }

            return true;
        }

        /// <summary>
        /// Internal Execution
        /// </summary>
        /// <param name="invocation">The invocation</param>
        /// <returns>A value indicating whether or not to continue.</returns>
        protected abstract bool ExecuteInternal(IInvocation invocation);
    }
}